package com.xwaf.platform.system.provider.util;

import java.lang.reflect.InvocationTargetException;
import java.util.Date;

import org.apache.commons.beanutils.BeanUtils;

import com.xwaf.platform.common.api.entity.TokenInfo;
import com.xwaf.platform.common.api.enums.DeviceType;
import com.xwaf.platform.system.api.entity.DataBase;
import com.xwaf.platform.system.api.entity.gateway.Token;

public class TestToken {

	public static void main(String[] args) throws IllegalAccessException, InvocationTargetException {
		long time = 720L;
		long loginTime = System.currentTimeMillis();
		TokenInfo tokenInfo = new TokenInfo();
		tokenInfo.setDeviceType(DeviceType.PC.name());
		tokenInfo.setLoginTime(new Date(loginTime));
		tokenInfo.setExpireAt(new Date(loginTime + time * 60 * 60 * 1000));
		tokenInfo.setExpiryInMilli(time * 60 * 60 * 1000);
		tokenInfo.setUserId("180");
		tokenInfo.setToken(DataBase.getDataBaseId(DataBase.TN));
		Token token = new Token();
		BeanUtils.copyProperties(token, tokenInfo);
		token.setId(DataBase.getDataBaseId(DataBase.TN));
		System.out.println(token);
	}
}
